package com.myfoon.model.cacheable;


import com.myfoon.model.entity.Event;

import com.tangosol.io.ExternalizableLite;
import com.tangosol.util.ExternalizableHelper;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import java.sql.Timestamp;


public class EventCache implements ExternalizableLite {    
    private Long id;
    private Long ownerId;
        
    private Timestamp date;
    private String message;
        
    private Timestamp created;
            
    
    public EventCache() {
    }
    
    public EventCache(Event event) {
        this.id = event.getId();
        this.ownerId = event.getOwner().getId();
                        
        this.date = event.getDate();
        this.message = event.getMessage();
        
        this.created = event.getCreated();              
    }

    public void readExternal(DataInput dataInput) throws IOException {
        id = ExternalizableHelper.readLong(dataInput);
        ownerId = ExternalizableHelper.readLong(dataInput);
        
        date = ExternalizableHelper.readTimestamp(dataInput);
        message = ExternalizableHelper.readSafeUTF(dataInput);
        
        created = ExternalizableHelper.readTimestamp(dataInput);    
    }

    public void writeExternal(DataOutput dataOutput) throws IOException {
        ExternalizableHelper.writeLong(dataOutput, id);
        ExternalizableHelper.writeLong(dataOutput, ownerId);
        
        ExternalizableHelper.writeTimestamp(dataOutput, date);
        ExternalizableHelper.writeSafeUTF(dataOutput, message);
        
        ExternalizableHelper.writeTimestamp(dataOutput, created);        
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setOwnerId(Long ownerId) {
        this.ownerId = ownerId;
    }

    public Long getOwnerId() {
        return ownerId;
    }

    
    public void setDate(Timestamp date) {
        this.date = date;
    }

    public Timestamp getDate() {
        return date;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getMessage() {
        return message;
    }
    
    public void setCreated(Timestamp created) {
        this.created = created;
    }

    public Timestamp getCreated() {
        return created;
    }
}
